<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button {
            color: green;
            background-color: #ccc;
        }
    </style>
</head>
<body>
    <button>1</button>
    <button>2</button>
    <button>3</button>
    <button>4</button>
    <button>5</button>
    <button>6</button>
    
    <script>
        // 排他思想
        var btns = document.getElementsByTagName('button');
        var p = document.getElementsByTagName('div');
        for(var i = 0; i < btns.length; i++) {
            btns[i].onclick = function() {
                for(var j = 0; j < btns.length; j++){
                    btns[j].style.backgroundColor = '#ccc'
                }
                this.style.backgroundColor = 'pink';
            }
        }   
    </script>
</body>
</html>